home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2002 January / maximum-cd-2002-01.iso / Files / Mechwarrior 4 Mapping / MW4Editor.exe / content / ABLScripts / GenericScripts / Patrol.tpl < prev    next >
Encoding:
Text File  |  2001-07-16  |  6.4 KB  |  190 lines

  1.  
  2. //------------------------------------------------------------------
  3. // NOTE: The fsm name below MUST be changed in order for the
  4. // script to be considered a unique entity!
  5.  
  6. UIFIELDS
  7. {
  8. FIELD<         INT,attackRange,"Attack Range",500>;        // At what range do I start shooting?
  9. FIELD<         INT,withdrawRange,"Withdraw Range",750>;        // At what range do I withdraw from combat entirely?
  10. FIELD<          INT,piloting,"Piloting Skill",50>;            // Piloting skill
  11. FIELD<          INT,gunnery,"Gunnery Skill",50>;            // Gunnery skill/chance to hit
  12. FIELD<          FLOAT,minDelay,"Minimum fire Delay",1.0>;            // Minimum amount of time I will wait between shots once a weapon is reloaded
  13. FIELD<          FLOAT,maxDelay,"Maximum fire Delay",2.0>;            // Maximum amount of time I will wait between shots once a weapon is reloaded
  14. FIELD<          INT,eliteLevel,"Elite Level",60>;            // Elite level.  This helps determine tactics, defensive manuevers, opportunity fire
  15.                                                     // and other things.  It indicates a general level of combat experience.
  16. FIELD<           INT,isShotRadius,"Is Shot Radius",120>;        // How far away from me will I detect an enemy shot?        
  17. FIELD<INT,    takeOffDistance,"Take Off Distance (ignored if not a plane)",160>;
  18. FIELD<INT,    attackThrottle,"Percent throttle when in combat",80>;
  19.  
  20. FIELD<          INT,path,"Path",-1>;                // My path
  21. FIELD<          INT,moveType,"Nocycle = 1, Circle = 2, Seesaw = 3",2>;            // How I move along the path
  22. FIELD<INT, speed,"Movement Speed",600>;        
  23.  
  24. }
  25.  
  26. fsm Generic_Patrol : integer;
  27.  
  28.  
  29. //------------------------------------------------------------------
  30.  
  31. // Generic_Patrol:
  32. //   Follows a path.  If anything comes near, it goes off and attacks it,
  33. //   and then comes back to the path when there's nothing left to attack.
  34.  
  35. //------------------------------------------------------------------
  36.  
  37.  
  38.  
  39. //------------------------------------------------------------------
  40. //     Constants
  41. //------------------------------------------------------------------
  42.  
  43.     const
  44.         #include_ <content\ABLScripts\mwconst.abi>
  45.  
  46. //------------------------------------------------------------------
  47. //     Types
  48. //------------------------------------------------------------------
  49.  
  50.     type
  51.         #include_ <content\ABLScripts\mwtype.abi>
  52.     
  53.  
  54. //------------------------------------------------------------------
  55. //     Variables
  56. //------------------------------------------------------------------
  57.  
  58.     var
  59.         static integer            attackRange;        // At what range do I start shooting?
  60.         static integer            withdrawRange;        // At what range do I withdraw from combat entirely?
  61.  
  62.         static integer            path;                // My path
  63.         static integer            moveType;            // How I move along the path
  64.         static boolean            canLeavePath;        // Can I leave the path if attacked? (TRUE by default)
  65.  
  66.         static integer            piloting;            // Piloting skill
  67.         static integer            gunnery;            // Gunnery skill/chance to hit
  68.         static real                minDelay;            // Minimum amount of time I will wait between shots once a weapon is reloaded
  69.         static real                maxDelay;            // Maximum amount of time I will wait between shots once a weapon is reloaded
  70.         static integer             eliteLevel;            // Elite level.  This helps determine tactics, defensive manuevers, opportunity fire
  71.                                                     // and other things.  It indicates a general level of combat experience.
  72.         static integer            attackThrottle;        // My attack throttle
  73.          static integer            isShotRadius;        // How far away from me will I detect an enemy shot?
  74.         static integer            findTypes;            // What kind of enemies to look for
  75.  
  76.         static integer             attackSound;        // The attack sound I play when I first attack
  77.         static integer             deathSound;            // The sound I play when I die
  78.         
  79.         static integer            mood;                // My default mood.
  80.         static integer            speed;                // The speed at which I move along the path
  81.  
  82.         static integer            takeOffDistance;    // My take-off distance if I'm an airplane (ignored if not an airplane)
  83.  
  84. //------------------------------------------------------------------
  85. //     Init: my initialization function
  86. //------------------------------------------------------------------
  87.  
  88. function Init;
  89.     code
  90.         // Variables set by editor
  91.         attackRange        = <attackRange>;
  92.         withdrawRange    = <withdrawRange>;
  93.         takeOffDistance    = <takeOffDistance>;
  94.          piloting        = <piloting>;
  95.         gunnery            = <gunnery>;
  96.         minDelay        = <minDelay>;
  97.         maxDelay        = <maxDelay>;
  98.         eliteLevel        = <eliteLevel>;
  99.         isShotRadius    = <isShotRadius>;
  100.     attackThrottle    = <attackThrottle>;
  101.  
  102.         path            = <path>;
  103.         moveType        = <moveType>;
  104.         speed            = <speed>;
  105.  
  106.         
  107.     canLeavePath    = true;
  108.         attackSound        = -1; // no sound
  109.         deathSound        = -1; // no sound
  110.         mood            = NEUTRAL_START;
  111.         findTypes        = FT_DEFAULT;
  112.  
  113. endfunction;
  114.  
  115. //------------------------------------------------------------------
  116. //    StartState: my initial state
  117. //------------------------------------------------------------------
  118.  
  119. state StartState;
  120.  
  121.     code
  122.         SetFiringDelay            (ME,minDelay,maxDelay);
  123.         SetIgnoreFriendlyFire    (ME,true);
  124.         SetIsShotRadius            (ME,isShotRadius);
  125.         SetEntropyMood            (ME,mood);
  126.         SetCurMood                (ME,mood);
  127.         SetSkillLevel            (ME,piloting,gunnery,eliteLevel);
  128.         SetAttackThrottle        (ME,attackThrottle);
  129.  
  130.         if (orderTakeOff(takeOffDistance) == true) then
  131.             trans FollowPathState;
  132.         endif;
  133.  
  134. endstate;            
  135.  
  136. //------------------------------------------------------------------
  137. //    FollowPathState: follow our path, but keep an eye out for enemies
  138. //------------------------------------------------------------------
  139.  
  140. state FollowPathState;
  141.     code
  142.         if (FindEnemy(attackRange,findTypes)) then
  143.             trans AttackState;
  144.         endif;
  145.  
  146.         if (path <> -1) then
  147.             OrderMoveResumePatrol(path,speed,moveType,true,false);
  148.         else
  149.             OrderMoveLookOut;
  150.         endif;
  151. endstate;
  152.  
  153. //------------------------------------------------------------------
  154. //    AttackState: attack my current target, or return to path if done
  155. //------------------------------------------------------------------
  156.  
  157. state AttackState;
  158.     code
  159.         if (LeaveAttackState(withdrawRange)) then
  160.             OrderStopAttacking;
  161.             SetTarget(ME,NO_UNIT);
  162.             trans FollowPathState;
  163.         endif;
  164.  
  165.         if (attackSound <> -1) then    
  166.             PlaySoundOnce(attackSound);
  167.         endif;
  168.  
  169.         OrderAttack(canLeavePath);
  170.  
  171. endstate;
  172.  
  173. //------------------------------------------------------------------
  174. //    DeadState: OK, I kicked the bucket.
  175. //------------------------------------------------------------------
  176.  
  177. state DeadState;
  178.     code
  179.         if (deathSound <> -1) then    
  180.             PlaySoundOnce(deathSound);
  181.         endif;        
  182.  
  183.         orderDie;
  184.  
  185. endstate;
  186.  
  187.  
  188. endfsm.
  189.  
  190.